package com.yodawnla.roboAttack;

import org.anddev.andengine.entity.sprite.AnimatedSprite;
import org.anddev.andengine.opengl.texture.region.TiledTextureRegion;

import com.yodawnla.lib.YoActivity;
import com.yodawnla.roboAttack.system.SE;
import com.yodawnla.roboAttack.system.Values;

public class Robot extends AnimatedSprite
{
	boolean mIsBeHit = false;
	
	public Robot(float pX, float pY, TiledTextureRegion pTiledTextureRegion)
	{
		super(pX, pY, pTiledTextureRegion);
	}
	
	public Robot(float pX, float pY,float width,float height ,TiledTextureRegion pTiledTextureRegion)
	{
		super(pX, pY, width,height,pTiledTextureRegion);
	}

	public void setIsbeHit(boolean isBeHit)
	{
		mIsBeHit = isBeHit;
		if(mIsBeHit)
		{
			if(Values.ROBO_LIFE  > 0)
				Values.ROBO_LIFE--;
             
			if(Values.ROBO_LIFE == 1)
				YoActivity.getBaseActivity().playSound(SE.Alarm);
			YoActivity.getBaseActivity().playSound(SE.Explosion);
			GameHud.getInstance().setHp(Values.ROBO_LIFE);
		}
	}
	
	public boolean getIsBeHit()
	{
		return mIsBeHit;
	}
	
	public void die()
	{
		Values.ROBO_ALIVE = false;
	}
	
	public void resetRobot()
	{
		clearEntityModifiers();
		setAlpha(1);
		setVisible(true);
		mIsBeHit = false;
		Values.ROBO_ALIVE = true;
		Values.ROBO_LIFE = Values.ROBO_MAX_LIFE;
		GameHud.getInstance().setHp(Values.ROBO_LIFE);
	}
}